<?php
//演示键值对用法
include('./'.DIRECTORY_SEPARATOR.'Credis.php');
$Credis=Credis::init();

echo "<br/>";
echo '写'.$rand=rand(10,99);
$Credis->set('user_'.$rand,$rand,2);
echo "<br/>";
echo '读'.$Credis->get('user_'.$rand,rand(100,999));
echo "<br/>";
echo '存在:';
echo $Credis->has('user_'.$rand)?'是':'否';
echo "<br/>";
echo '删除'.$Credis->delete('user_'.$rand);
echo "<br/>";
echo '存在:';
echo $Credis->has('user_'.$rand)?'是':'否';
$keys=[];
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo '写'.$rand=rand(10,99);
$Credis->set('user_'.$rand,$rand,2);
echo "<br/>";
echo '存在:';
echo $Credis->has('user_'.$rand)?'是':'否';
echo "<br/>";
echo 'flush'.$Credis->flush('user_'.$rand);
echo "<br/>";
echo '存在:';
echo $Credis->has('user_'.$rand)?'是':'否';
$keys=[];
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo '测试pipe';
for ($i=0;$i<50;$i++) {
    // code...
    $rand=rand(1,99);
    if($i%2==0){
        $Credis->set('pipe_'.$rand,$rand,5);
    }
    if($i%3==0){
        $keys[]='pipe_'. $rand;
    }
}
echo "<br/>";
($Credis->pipe($keys));
?>